const person = { firstName: "John", lastName: "Doe" };

// preventExtensions：使对象不可扩展
{
  Object.preventExtensions(person);
  // person.age = 20; // TypeError: Cannot add property age, object is not extensible
}

// isExtensible：检查对象是否可扩展
{
  console.log(Object.isExtensible(person));
}

// seal： 防止添加或删除新属性，使现有属性不可配置
{
  Object.seal(person);
  // delete person.firstName; // TypeError: Cannot delete property 'firstName' of #<Object>
}

// isSealed：检查对象是否密封
{
  let answer = Object.isSealed(person);
  console.log(answer);
}

// freeze：防止添加或删除新属性，现有属性不可配置，现有属性值不可修改
{
  Object.freeze(person);

  // person.firstName = "123"; // TypeError: Cannot assign to read only property 'firstName' of object '#<Object>'
}

// isFrozen：检查对象是否被冻结
{
  console.log(Object.isFrozen(person));
}
